/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2024-2024. All rights reserved.
 * Description: local ipc notify interface
 */

#ifndef LOCAL_IPC_NOTIFY_H
#define LOCAL_IPC_NOTIFY_H

#include "stream_pub.h"
#include "dispatcher.h"
#include "local_notify.h"

namespace hccl {
class LocalIpcNotify : public LocalNotify {
public:
    LocalIpcNotify();
    ~LocalIpcNotify();
    HcclResult Init(const s32 localDeviceId, const s32 remoteDeviceId,
        const NotifyLoadType type = NotifyLoadType::HOST_NOTIFY);
    HcclResult Init(const HcclSignalInfo &notifyInfo,
                    const NotifyLoadType type = NotifyLoadType::DEVICE_NOTIFY);
    HcclResult Serialize(std::vector<u8> &byteVector);

    HcclResult Wait(Stream& stream, HcclDispatcher dispatcher,
        s32 stage = INVALID_VALUE_STAGE, u32 timeOut = NOTIFY_DEFAULT_WAIT_TIME,
        u32 userRank = INVALID_UINT, u32 remoteUserRank = INVALID_UINT);
    HcclResult Post(Stream& stream, HcclDispatcher dispatcher,
        s32 stage = INVALID_VALUE_STAGE, u32 remoteUserRank = INVALID_UINT);
    HcclResult Grant(s64 recvId);

    void Break();

    void SetEventIdAndTid(const u32 eventId, const u32 tid);

    static HcclResult Wait(Stream& stream, HcclDispatcher dispatcherPtr, const std::shared_ptr<LocalIpcNotify> &notify,
        s32 stage = INVALID_VALUE_STAGE, u32 timeOut = NOTIFY_DEFAULT_WAIT_TIME,
        u32 userRank = INVALID_UINT, u32 remoteUserRank = INVALID_UINT);
    static HcclResult Post(Stream& stream, HcclDispatcher dispatcherPtr, const std::shared_ptr<LocalIpcNotify> &notify,
        s32 stage = INVALID_VALUE_STAGE, u32 remoteUserRank = INVALID_UINT);

    u64 offset  = INVALID_U64;
    u64 address = INVALID_U64;
};
}

#endif // LOCAL_IPC_NOTIFY_H
